package com.atguigu.assionexcel;

import com.alibaba.excel.EasyExcel;
import com.atguigu.assionexcel.entity.User;
import com.atguigu.assionexcel.invoke.MyListenner;
import org.junit.Test;

import javax.xml.crypto.Data;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @author senior
 * @create 2021-11-09 20:54
 */

public class WritTestExcel {
    @Test
    public  void main2() {
        //必须有存在的文件夹和文件
        String filename = "D:/cache/a.xlsx";

        EasyExcel.write(filename,User.class).sheet("模板").doWrite(list());
    }
    public List<User> list(){
        List<User> list = new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            User user = new User();
            user.setName(i + "zhangsan");
            user.setEmail(i + "@168.com.zhangsan");
            list.add(user);
        }
        return list;
    }
    //读的方法
    @Test
    public void excelRead(){
        String filename = "D:/cache/a.xlsx";

        EasyExcel.read(filename,User.class,new MyListenner()).sheet().doRead();
    }
}
